package com.kyzh.core.pager.me.user

import android.os.Bundle
import com.google.gson.Gson
import com.gushenge.core.base.activity.BaseActivity
import com.gushenge.core.impls.UserImpl
import com.gushenge.core.listeners.ResultListener
import com.kyzh.core.R
import kotlinx.android.synthetic.main.act_verified.*
import org.jetbrains.anko.toast

class VerifiedActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.act_verified)
        initView()
    }

    private fun initView() {
        commit.setOnClickListener {
            val name = et1.text.toString()
            val number = et2.text.toString()
            when{
                name.isEmpty()->toast(getString(R.string.nameIsNotEmpty))
                number.isEmpty()->toast(getString(R.string.idcardIsNotEmpty))
                else->{
                    val map = hashMapOf<String,String>()
                    map["name"] = name
                    map["idcard"] = number
                    UserImpl.changeUserInfo(Gson().toJson(map),object : ResultListener {
                        override fun success(message: Any) {
                            toast(message as String)
                            finish()
                        }

                        override fun error(error: String) {
                            toast(error)
                        }
                    })
                }
            }
        }
    }

}
